using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class GameManager : MonoBehaviour//计数系统
{
    public TextMeshProUGUI scoreText2;
    public TextMeshProUGUI scoreText;
    public TextMeshProUGUI highscoreText;
    private float Score;
    private float HighScore;
    // Start is called before the first frame update
    public void IncreaseScore()
    {
       
        Score++;
        UpdateScoreDisplay();
    }
    private void Start()
    {
        
        HighScore = PlayerPrefs.GetFloat("HighScore", 0f);
        UpdateScoreDisplay();
    }

    // Update is called once per frame
    void Update()
    {
        scoreText.text = Score.ToString();
        scoreText2.text = Score.ToString();
        highscoreText.text = HighScore.ToString();

        if (Score > HighScore)
        {
            HighScore = Score;
            PlayerPrefs.SetFloat("HighScore", HighScore);
            highscoreText.text = HighScore.ToString();
        }
    }
    void UpdateScoreDisplay()
    {
        scoreText.text = Score.ToString();
        scoreText2.text = Score.ToString();
    }
}
